<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="/struts-tags" prefix="s" %>  

<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />

		<!--[if gt IE 8]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />        
    <![endif]-->

		<title>报名系统</title>

		<%@include file="res.jsp"%>

		<%@include file="htmledit.jsp"%>
		 
	</head>
	<body>

		<jsp:include page="header.jsp"></jsp:include>

		<jsp:include page="menu.jsp"></jsp:include>

		<jsp:include page="com_bbs.jsp"></jsp:include>

		<div class="content">

			<div class="row-fluid">

				<div class="span7">
					
					<div class="page-header">
			            <h1>${global_member.name }站点的基本信息 <small></small></h1>
			        </div>
					
					<div class="row-fluid typography">
    
            <div class="widget">
                <c:choose>
                	<c:when test="${tip == 'success'}">
                		<div class="block">
                     		首页链接：<br/>
                     		<c:choose>
                     			<c:when test="${empty site.siteCode}">
                     				<a href="<%=basePath %>d_${global_member.id }.do" target="_blank">
		                     			<%=basePath %>d_${global_member.id }.do
		                     		</a>
		                     		<p></p>
		                     		<p>你的网站链接比较长，你可以在左下角的<b><唯一码></b>里输入比较容易记的词，
		                     		比如：输入<b>123</b>，则链接变成&nbsp;<b><%=basePath %>d_123.do</b>&nbsp;<b>此值为固定，要想好哦</b></p>
                     			</c:when>
                     			<c:otherwise>
                     				<a href="<%=basePath %>d_${site.siteCode}.do" target="_blank">
		                     			<%=basePath %>d_${site.siteCode}.do
		                     		</a>
                     			</c:otherwise>
                     		</c:choose>
                     		 
		                    <h5>名称：${site.name }</h5> 
		                    <h5>图标:</h5> 
		                    <div class="row-fluid">
		                        <div class="span12">
		                        	<c:choose>
		                        		<c:when test="${!site.picPath}">
		                        			 <img style="max-width:90%" align="left" class="img-polaroid" src="${site.picPath }">
		                        		</c:when>
		                        		<c:otherwise>
		                        			 <img style="max-width:90%" align="left" class="img-polaroid" src="img/site/default.jpg">
		                        		</c:otherwise>
		                        	</c:choose> 
		                        </div>
		                    </div>
		                    <h5>描述：${site.describes }</h5> 
		                    <h5>版权：${site.copyRight }</h5> 
		                    <div class="clearfix"></div>
		                    
		                </div>
                	</c:when>
                	<c:when test="${tip == 'error'}">
	                	<div class="block">
	                		<h3>你的站点还没有建立 </h3>
	                	</div>
                	</c:when>
                </c:choose> 
            </div>            
                 
        </div>

				</div>

				<div class="span4">

					<div class="widget">
						<form action="page/site_modify.action" id="validate" method="post" enctype="multipart/form-data"> 
						<div class="head dark">
							<div class="icon">
								<i class="icos-pencil2"></i>
							</div>
							<h2>
								编辑站点
							</h2>
						</div>
						<div class="block-fluid">
							<input type="hidden" name="id" value="${site.id }" >
							<div class="row-form">
								<div class="span2">
									名称
								</div>
								<div class="span10">
									<input type="text" value="${site.name }" class="validate[required],minSize[3],maxSize[40]" name="name" placeholder="网站的名称">
									<span class="bottom" style="color:red"><s:fielderror fieldName="name"/></span>
								</div>
							</div>
							<div class="row-form">
								<div class="span2">
									描述
								</div>
								<div class="span10">
									<textarea name="describes" class="validate[required],minSize[3],maxSize[500]" placeholder="站点的描述">${site.describes }</textarea>
									<span class="bottom" style="color:red"><s:fielderror fieldName="describes"/></span>
								</div>
							</div>
							<div class="row-form">
								<div class="span2">
									海报 
								</div>
								<div class="span10"> 
									<c:choose>
			                        		<c:when test="${!site.picPath}">
												<c:choose> 
													<c:when test="${fn:contains(header['User-Agent'],'Chrome') || fn:contains(header['User-Agent'],'Firefox')}">
														 <div class="input-append file"> 
															  <input type="file" name="pic" >
					                                   	 	  <input placeholder=""  type="text" > 
														  </div>
													</c:when>
													<c:otherwise> 
													 		<input type="file" name="pic" >
													</c:otherwise>
												</c:choose>
											</c:when>
											<c:otherwise>
												<c:choose> 
													<c:when test="${fn:contains(header['User-Agent'],'Chrome') || fn:contains(header['User-Agent'],'Firefox')}">
														 <div class="input-append file"> 
															  <input class="validate[required]" type="file" name="pic" >
					                                   	 	  <input class="validate[required]" placeholder=""  type="text" > 
														  </div>
													</c:when>
													<c:otherwise> 
													 		<input class="validate[required]" type="file" name="pic" >
													</c:otherwise>
												</c:choose>
											</c:otherwise>
									 </c:choose>
									<span class="bottom" style="color:red"><s:fielderror fieldName="pic"/></span>
								</div>
							</div>
							 
							<div class="row-form">
								<div class="span2">
									版权:
								</div>
								<div class="span10"> 
									<input type="text" class="validate[required],minSize[3],maxSize[15]" value="${site.copyRight }" name="copyRight" placeholder="底部的版权信息">
									<span class="bottom" style="color:red"><s:fielderror fieldName="copyRight"/></span>
								</div>
							</div>

							<div class="toolbar bottom TAL">
								<button class="btn btn-primary">
									保存
								</button>
							</div>

						</div>
						</form>
					</div>
				<c:if test="${!empty site && empty site.siteCode}">
					<div class="widget">
	                
	              	   <script type="text/javascript">
	              	   		function check_site_code()
	              	   		{ 
	                  	   		var site_code_value = $("#site_code_value").val() ; 
	                  	   		var id = $("#siteId_code").val() ;  
	                  	   		
	                  	   		//Ajax提交 
	                  	   		 $.get("page/site_urlcode.action?siteCode="+site_code_value+"&id="+id,function(data,status){
								    if(data.indexOf("4") >= 0 ){
										alert("更新成功") ; 
										window.location.href="<%=basePath %>page/site_edit.action" ; 
									}else if(data.indexOf("2") >= 0)
									{
										alert("已经存在唯一码") ; 
									}
									else if(data.indexOf("1") >= 0)
									{
										alert("非法输入") ; 
									}
									else if(data.indexOf("3") >= 0)
									{
										alert("你还没有建立站点") ; 
									}
								  });
	                  	   		 
	                  	   		return false ; 
	              	   		}
	              	   </script> 
							<div class="block-fluid">
								<input type="hidden" id="siteId_code" name="id" value="${site.id }" >
								<div class="row-form">
									<div class="span2">
										唯一码
									</div>
									<div class="span10">
										<input type="text" id="site_code_value" class="validate[required,custom[integer],minSize[3],maxSize[10]" name="siteCode" placeholder="唯一码">
									</div>
								</div> 
								<div class="toolbar bottom TAL">
									<a class="btn btn-primary" onclick="check_site_code();">
										保存
									</a>
								</div>
	
							</div> 
	
	                </div>	
                </c:if>
				</div>
 
			</div>

		</div>

	</body>
</html>
